#define MAX_ENTERS 100
//-------------------------------------|
enum ENTER_DATA
{
Float:p_X,
Float:p_Y,
Float:p_Z,
Float:i_X,
Float:i_Y,
Float:i_Z,
iin
}

new EnterInfo[MAX_ENTERS][ENTER_DATA];
new InEnter[MAX_PLAYERS] = {-1,...};
new EnterCount = -1;

forward GetPlayerDistanceToPointEx(playerid,Float:x,Float:y,Float:z);
forward IsPlayerInSphere(playerid,Float:x,Float:y,Float:z,radius);
forward CreateEnter(Name[],Float:pX, Float:pY, Float:pZ, Float:iX, Float:iY, Float:iZ,ii);

stock GetPlayerEnter(playerid){
for(new e=0;e<EnterCount+1;e++)
{
	if(IsPlayerInRangeOfPoint(playerid,2,EnterInfo[e][p_X],EnterInfo[e][p_Y],EnterInfo[e][p_Z]))
	{
		return e;
	}
}
return -1;
}

public CreateEnter(Name[],Float:pX, Float:pY, Float:pZ, Float:iX, Float:iY, Float:iZ,ii)
{
	EnterCount ++;
	if(EnterCount < MAX_ENTERS)
	{
		if(EnterCount == 0){
		for(new i; i<MAX_ENTERS;i++){
		}
	}
	    Create3DTextLabel(Name,0xFF0000FF,pX,pY,pZ,20,0);
		EnterInfo[EnterCount][p_X] = pX;
		EnterInfo[EnterCount][p_Y] = pY;
		EnterInfo[EnterCount][p_Z] = pZ;
		EnterInfo[EnterCount][i_X] = iX;
		EnterInfo[EnterCount][i_Y] = iY;
		EnterInfo[EnterCount][i_Z] = iZ;
		EnterInfo[EnterCount][iin] = ii;
	}
}

forward OnEnterPlayerKeyStateChange(playerid, newkeys, oldkeys);
public OnEnterPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys == KEY_SECONDARY_ATTACK)
	{
	if(InEnter[playerid] == -1)
		{
		new e = GetPlayerEnter(playerid);
		if(IsPlayerInRangeOfPoint(playerid,2,EnterInfo[e][p_X],EnterInfo[e][p_Y],EnterInfo[e][p_Z]))
		{
			SetPlayerPos(playerid,EnterInfo[e][i_X],EnterInfo[e][i_Y],EnterInfo[e][i_Z]);
			SetPlayerInterior(playerid, EnterInfo[e][iin]);
			InEnter[playerid] = e;
			SendClientMessage(playerid, 0xFF0000AA, "For exit press {FFFFFF}ENTER");
		}
	}else{
			new EnterId = InEnter[playerid];
			if(IsPlayerInRangeOfPoint(playerid,7,EnterInfo[EnterId][i_X],EnterInfo[EnterId][i_Y],EnterInfo[EnterId][i_Z]))
			{
				SetPlayerPos(playerid,EnterInfo[EnterId][p_X],EnterInfo[EnterId][p_Y],EnterInfo[EnterId][p_Z]);
				SetPlayerInterior(playerid,0);
				InEnter[playerid] = -1;
			}}}
	return 1;
}
